package cn.edu.usst.cs.goldfish.booking.meetingroom.mybatis;

import cn.edu.usst.cs.goldfish.booking.meetingroom.model.MeetingSlot;
import cn.edu.usst.cs.goldfish.booking.meetingroom.web.dto.booking.Slot;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MeetingSlotMapper extends BaseMapper<MeetingSlot> {

    @Select("""
                    DELETE
                    FROM meeting_slot
                    WHERE meeting_id = #{meetingId}
            """)
    void deleteByMeetingId(@Param("meetingId") Long meetingId);

    @Select("""
                    SELECT id, date, hour, part
                    FROM meeting_slot
                    WHERE meeting_id = #{meetingId}
                    ORDER BY date ASC, hour ASC, part ASC
            """)
    List<MeetingSlot> selectByMeetingId(@Param("meetingId") Long meetingId);
}
